function deepClone(obj) {
    // 如果是基本数据类型，和null,直接输出
    if (typeof obj === null || typeof obj !== 'object') {
        return obj
    }

    // obj 类型
    const temp = new obj.constructor();
    for (let key in temp) {
        temp[key] = deepClone(obj[temp]);
    }

    return temp;
}

function deepCloneV2(obj, wk = new WeakMap()) {
  if (obj instanceof Object) {
    if (wk.has(obj)) {
      return wk.get(obj);
    }
    let newObj;

    if (obj instanceof Array) {
      newObj = [];
    } else if (obj instanceof Function) {
      newObj = function () {
        return obj.apply(this, arguments);
      };
    } else if (obj instanceof RegExp) {
      return new RegExp(obj);
    } else if (obj instanceof Date) {
      return new Date(obj);
    } else {
      newObj = {};
    }

    let desc = Object.getOwnPropertyDescriptors(obj);
    let value = Object.create(Object.getPrototypeOf(obj), desc);
    wk.set(obj, value);
    for (let key in obj) {
      if (obj.hasOwnProperty(key)) {
        newObj[key] = deepCloneV2(obj[key]);
      }
    }

    return newObj;
  }

  return obj;
}